#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include "../Includes/Driver.h"
#include "../Includes/Rendering.h"
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
#include <time.h>

/// <summary>
/// Locals
/// </summary>
cpu_set_t mask;
pthread_t thread;
pthread_mutex_t lock1;
pthread_mutex_t lock2;

/// <summary>
/// TODO
/// </summary>
int GCSStart(void)
{
	/* Startup */
	if (pthread_create(&thread, NULL, GCSRunning, NULL) != 0)
		return -1;
	return 0;
}

/// <summary>
/// TODO
/// </summary>
int GCSStartup(void) {
	
	//pthread_attr_setaffinity_np();

	return 0;
}

/// <summary>
/// TODO
/// </summary>
int GCSDispatch(void) {
	
	//pthread_attr_setaffinity_np();

	return 0;
}

/// <summary>
/// TODO
/// </summary>
int GCSShutdown(void) {
	
	//pthread_attr_setaffinity_np();

	return 0;
}

/// <summary>
/// TODO
/// </summary>
void* GCSRunning(void* ptr) {

	if (GCSStartup() < 0)
		return NULL;

	for (;;) {
		//if (stopp)
		//	break;
		//printf("Thread\n");
		usleep(1000000);
	}
	if (GCSShutdown() < 0)
		return NULL;

	return NULL;
}

/// <summary>
/// TODO
/// </summary>
int GCSStop(void)
{
	if (pthread_cancel(thread) != 0)
		return -1;
	return 0;
}
